package org.ttitfly.ttcore.entity.account;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.ttitfly.ttcore.entity.IdEntity;
@Entity
//表名与类名不相同时重新定义表名.
@Table(name = "s_resource")
//默认的缓存策略.
//@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Resource extends IdEntity{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	//名称
	@Column(name = "title")
	private String title;
	
	//排序
	@Column(name = "url")
	private String url;
	
	private List<Role> roles = new ArrayList<Role>();
	
	public String getTitle() {
		return title;
	}


	public void setTitle(String title) {
		this.title = title;
	}

	public String getUrl() {
		return url;
	}


	public void setUrl(String url) {
		this.url = url;
	}
	
	@ManyToMany(mappedBy="resources",fetch=FetchType.EAGER)
	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}
